<template>
  <div class="number-item-block" :style="'background-image: linear-gradient('+color[0]+','+color[1]+')'">
    <div class="name-block">
      <div class="icon iconfont" :class="icon"></div>
      <div class="name">{{name}}/{{unit}}</div>
    </div>
    <div class="number"><span class="unit">{{id==1? '已开工':'已完成' }}</span>{{completeThousands}}</div>
<!--    <dv-digital-flop class="number" :config="{number:[number],content:'共计{nt}',formatter:formatter,style:{fill:'#fff'}}"/>-->
    <div class="complete">共计&nbsp;{{thousands}}</div>
  </div>
</template>

<script>
export default {
  name: "NumberItem",
  props:{
    name:{
      type:String,
      default:'',
    },
    icon:{
      type:String,
      default:'',
    },
    unit:{
      type:String,
      default:'',
    },
    number:{
      type:Number,
      default:0,
    },
    complete:{
      type:Number,
      default:0,
    },
    color:{
      type:Array,
      default:()=>['#0a88ec','#2b59f7']
    },
    id:{
      type:Number,
      default:1,
    }
  },
  methods:{
    formatter(number){
      return number>0?Math.round(number).toLocaleString():0;
    }
  },
  computed:{
    thousands(){
      return this.number.toLocaleString();
    },
    completeThousands(){
      return this.complete.toLocaleString()
    }
  }
}
</script>

<style scoped lang="scss">
.number-item-block{
  display: flex;
  flex-direction: column;
  padding-left: 15px;
  height: 100%;
  border-radius: 5px;
  justify-content: center;
  position: relative;
  .name,.icon,.number,.unit{
    color: #fff;
  }
  .name-block{
    width: 100%;
    display:flex;
    flex-direction: row;
    align-items: center;
    font-size: 14px;
    .icon{
      margin-right: 5px;
      font-size: 18px;
    }
  }
  .number{
    text-align: left;
    margin-top: 10px;
    font-size: 28px;
    font-weight: bold;
    .unit{
      font-size: 14px;
      margin-right: 5px;
    }
  }
  .complete{
    font-size: 14px;
    color: #fff;
    margin-top: 10px;
  }
}
</style>
